$(function() {

	showMessage();
});

// 加载学员信息
function showMessage() {
	$
			.ajax({
				url : "/vi_user_student/selectByUid",
				type : "post",
				success : function(data) {

					// 改变头像图片源
					if (data.headImage == ""|| data.headImage==null) {
						//设置默认头像图片
						$("#my-img").attr("src", "/images/滑稽.png");
						}
					else{
					$("#my-img").attr("src", "/images/" + data.headImage);
					}
					// 通过改变 text的value值来显示的信息
					var content = '<div class="layui-form-item" style="font-size: 20px; text-align: center" >基本信息</div>';
					var nickName = '<label class="layui-form-label" ">昵称</label>'
							+ '<div class="layui-input-inline">';
					if (data.nickName==null ||data.nickName == "") {
						nickName += '<input type="text" disabled="disabled" placeholder="未知" name="nickName"  required lay-verify="required" disabled="disabled" autocomplete="off" class="layui-input">';
					} else {
						nickName += '<input type="text" disabled="disabled" name="nickName"  required lay-verify="required" value="'
								+ data.nickName
								+ '" disabled="disabled" autocomplete="off" class="layui-input">';
					}
					nickName += '</div>';
					var sname = '<label class="layui-form-label" ">姓名</label>'
							+ '<div class="layui-input-inline">';
					if (data.sname==null ||data.sname == "") {
						sname += '<input type="text" disabled="disabled" placeholder="未知" name="sname"  required lay-verify="required"  autocomplete="off" class="layui-input">';
					} else {
						sname += '<input type="text" disabled="disabled" name="sname"  required lay-verify="required" value="'
								+ data.sname
								+ '"  autocomplete="off" class="layui-input">';
					}
					sname += '</div>';

					var ssex = '<label class="layui-form-label" ">性别</label>'
							+ '<div class="layui-input-inline">';
					if (data.ssex==null||data.ssex == "") {
						ssex += '<input type="text" disabled="disabled" placeholder="未知" name="ssex"  required lay-verify="required"  autocomplete="off" class="layui-input">';
					} else {
						ssex += '<input type="text" disabled="disabled" name="ssex"  required lay-verify="required" value="'
								+ data.ssex
								+ '"  autocomplete="off" class="layui-input">';
					}
					ssex += '</div>';

					var sage = '<label class="layui-form-label" ">年龄</label>'
							+ '<div class="layui-input-inline">';
					if (data.sage==null||data.sage == "") {
						sage += '<input type="text" disabled="disabled" placeholder="未知" name="sage"  required lay-verify="required"  autocomplete="off" class="layui-input">';
					} else {
						sage += '<input type="text" disabled="disabled" name="sage"  required lay-verify="required" value="'
								+ data.sage
								+ '"  autocomplete="off" class="layui-input">';
					}
					sage += '</div>';

					var address = '<label class="layui-form-label" ">地址</label>'
							+ '<div class="layui-input-inline">';
					if (data.address==null||data.address == "") {
						address += '<input type="text" disabled="disabled" id="add" placeholder="未知" name="address"  required lay-verify="required"  autocomplete="off" class="layui-input">';
					} else {
						address += '<input type="text" disabled="disabled" id="add" name="address"  required lay-verify="required" value="'
								+ data.address
								+ '"  autocomplete="off" class="layui-input">';
					}
					address += '</div>';
                    
					
					if(data.publicLevel==0){
						data.publicLevel="公开(所有人可见)";
					}
					if(data.publicLevel==1){
						data.publicLevel="好友可见";
					}
					if(data.publicLevel==2){
						data.publicLevel="私密(仅自己可见)";
					}
					var publicLevel = ' <div class="layui-form-item">'
							+ '<label class="layui-form-label">信息级别</label>'
							+ '<div class="layui-input-inline">'
							+ '<input type="text" name="publicLevel" value="'
							+ data.publicLevel
							+ '" disabled="disabled" required lay-verify="required"  autocomplete="off" class="layui-input">'
							+ '</div></div>'

				  var sintroduction ='<div class="layui-form-item ">'
							    +'<label class="layui-form-label">自我介绍</label>'
							    +'<div class="layui-input-inline" style="width: 70%;">'
							     +' <textarea name="sintroduction"  disabled="disabled" class="layui-textarea">'+data.sintroduction+'</textarea>'
							     +' </div></div>'	
							
							
				    var botton = '<div class="layui-form-item">'
							+ '<div class="layui-input-block">'
							+ '<input type="button" class="layui-btn" onclick="set()" value="编辑">'
							+ '</div></div>'

					
					content += '<div class="layui-form-item">' 
						    + nickName
							+ sname 
							+ '</div>' 
							+ '<div class="layui-form-item">' 
							+ ssex
							+ sage
							+ '</div>' 
							+ '<div class="layui-form-item">' 
							+ address
							+ '</div>' 
							+ publicLevel 
							+sintroduction
							+ botton;
					$("#updateMessage").html(content)
					/* $("two").html(content) */
				}
			});
}
function set() {
	location.href = "/html/studentCompile.html";
}